package com.zxt.recruit;

import com.zxt.recruit.util.EncryptionUtils;
import jakarta.annotation.Resource;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;

@SpringBootTest(classes = Application.class,webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class encoder {

    @Resource
    EncryptionUtils encryptionUtils;

    @Test
    void testPassword(){
        String password = "poxiaodi";
        PasswordEncoder encoder=new BCryptPasswordEncoder();
        String encoded = encoder.encode(password);
        System.out.println(encoded);
        System.out.println(encoder.matches(encoded, password));
        System.out.println(encoder.matches(password, encoded));
        System.out.println(encoder.matches(encoded, "poxiaojun"));
    }

    @Test
    void testEncoder() throws Exception {
        String password = "poxiaodi";
        String poxiaodi = encryptionUtils.en("poxiaodi");
        System.out.println(poxiaodi);
        System.out.println(encryptionUtils.en("poxiaodi"));

        System.out.println(encryptionUtils.de(poxiaodi));
    }



}
